package main

import (
	"FlyBird/util"
	"math/rand"
	"time"
)


func deal()  {

//********************************** 新版本，通过改变 值。老元素给新值
	if len(obstacles) > 0 {
		rand.Seed(time.Now().UnixNano())

		for i := 0; i < len(obstacles); i++{
			if obstacles[i].X < -50 {
				obstacles[i].TopLength = util.Random(15,2)
				// 移除超出屏幕的障碍物
				del := obstacles[0]
				del.X = obstacles[len(obstacles)-1].X+180
				ran := util.Random(15,2)
				ran1 := util.Random(180,80)
				del.TopLength = ran
				del.HoverUPY = ran1
				del.HoverBottomY = ran1 + 20*ran
				del.BarrierStates = util.Random(3,0)
				del.isScore = false
				obstacles = append(obstacles[:i], obstacles[i+1:]...)
				// 添加新的障碍物到切片末尾
				obstacles = append(obstacles, del)
			}
		}
	}



}
